My Win32/C++ High Resolution Timer from VDEngine
------------------------------------------------

         __int64 highResolutionPerformanceCount = 0;
         __int64 highResolutionPerformanceCounterFrequency = 0;
          double gameUpdateCount = 0.0f;
          double currentTime = 0.0f;
    const double gameUpdateFrequency = 90.0f;
    const double maxSecondsForOneGameUpdate = 1 / gameUpdateFrequency;
         __int64 newCount;

    // initialize the high performance timer
    BOOL returnValue = QueryPerformanceFrequency((LARGE_INTEGER *) &highResolutionPerformanceCounterFrequency);
    if (returnValue == FALSE) {
        VDError("Failed to retrieve the frequency of the high-resolution performance counter.", __FILE__, __LINE__);
    };
    returnValue = QueryPerformanceCounter((LARGE_INTEGER *) &highResolutionPerformanceCount);
    if (returnValue == FALSE) {
        VDError("Failed to retrieve the current value of the high-resolution performance counter.", __FILE__, __LINE__);
    };
    double accumulator = 0.0f;

    // game loop
    while (gameRunning) {
        // get the current count
        returnValue = QueryPerformanceCounter((LARGE_INTEGER *) &newCount);
        if (returnValue == FALSE) {
            VDError("Failed to retrieve the current value of the high-resolution performance counter.", __FILE__, __LINE__);
        };

        int updatesPerCycle = 0;

        // acquire the time it took to run one cycle
        double deltaTime = (double) (newCount - highResolutionPerformanceCount) / highResolutionPerformanceCounterFrequency;
        highResolutionPerformanceCount = newCount;
        currentTime = (double) highResolutionPerformanceCount / highResolutionPerformanceCounterFrequency;

        // clamp the time in case we lose focus of the thread for a while
        if (deltaTime > 0.25) {
            deltaTime = 0.25;
        };

        // allow the accumulator to process as many updates required to catch up to our provided Hz
        accumulator += deltaTime;
        while (accumulator >= maxSecondsForOneGameUpdate) {
            // game logic
            UpdateGame(currentTime);
            updatesPerCycle++;
            gameUpdateCount += maxSecondsForOneGameUpdate;
            accumulator -= maxSecondsForOneGameUpdate;
        };

        // render
    };
}


SO FOR UNIX:
------------

    timeval start_count;
    timeval end_count;

    /* type(tv_sec) == type(tv_usec) == long */
    long elapsed_time = ((end_count.tv_sec - start_count.tv_sec) * 1000.0)
                      + ((end_count.tv_usec - start_count.tv_usec) / 1000.0);


AND WINDOWS:
------------

    LARGE_INTEGER frequency;
    LARGE_INTEGER start_count;
    LARGE_INTEGER end_count;

    /* type(QuadPart) == LONGLONG == signed __int64 */
    double elapsedTime = (end_count.QuadPart - start_count.QuadPart) * 1000.0 / frequency.QuadPart;
